package com.tmall.wireless.vaf.virtualview.view.scroller;

import com.libra.virtualview.common.ScrollerCommon;
import com.tmall.wireless.vaf.Log;
import ohos.agp.components.ListContainer;
import com.tmall.wireless.vaf.framework.VafContext;

public class ScrollerImp extends ListContainer {
    protected VafContext mAppContext;
    protected Scroller mScroller;
    protected ScrollerRecyclerViewAdapter mAdapter;


    public ScrollerImp(VafContext vafContext, Scroller scroller) {
        super(vafContext.forViewConstruction());
        mAppContext = vafContext;
        mScroller = scroller;
        mAdapter = new ScrollerRecyclerViewAdapter(vafContext, this);
        this.setItemProvider(mAdapter);
    }
    public void setData(Object str) {
        // parse data
        mAdapter.setData(str);
        mAdapter.notifyDataChanged();
    }

    public void appendData(Object data) {
        mAdapter.appendData(data);
    }

    public void destroy() {
        mScroller = null;
        mAdapter.destroy();
        mAdapter = null;
    }

    public void setAutoRefreshThreshold(int threshold) {
        mAdapter.setAutoRefreshThreshold(threshold);
    }

    public void callAutoRefresh() {
        mScroller.callAutoRefresh();
    }


    public void setModeOrientation(int mode, int orientation) {
        switch (mode) {
            case ScrollerCommon.MODE_StaggeredGrid:
                setOrientation(orientation);
                break;
            default:
                Log.i("mode invalidate:" + mode);
                break;
        }
    }


}
